<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<input type="file"> <button id="btn">提交</button>  
<script>
    const btn = document.getElementById("btn")
    btn.onclick = function (){
        
        const formdata = new FormData() 
        const fileDom = document.querySelector("input")
        const file = fileDom.files[0]
        formdata.append("file",file)
        const xhr = new XMLHttpRequest()
        xhr.open("post","http://localhost:5000/test")        
        xhr.send(formdata)
    }
</script>
</body>
</html>